﻿namespace DueDatePickerSample.Converters
{
    using System;
    using System.Windows.Data;
    using DueDatePickerSample.Controls;

    public class DueDateToNameConverter : IValueConverter
    {
        public object Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value != null)
            {
                var dueDateValue = (DueDatePickerPage.DueDate)value;

                switch (dueDateValue)
                {
                    case DueDatePickerPage.DueDate.CustomDate:
                        return "custom";

                    case DueDatePickerPage.DueDate.NoDueDate:
                        return "no due date";

                    case DueDatePickerPage.DueDate.Today:
                        return "today";

                    case DueDatePickerPage.DueDate.Tomorrow:
                        return "tomorrow";

                    case DueDatePickerPage.DueDate.TwoDaysLater:
                        return DateTime.Today.AddDays(2).DayOfWeek;

                    case DueDatePickerPage.DueDate.ThreeDaysLater:
                        return DateTime.Today.AddDays(3).DayOfWeek;

                    case DueDatePickerPage.DueDate.FourDaysLater:
                        return DateTime.Today.AddDays(4).DayOfWeek;
                }
            }

            return "CONVERT_ERROR";
        }

        public object ConvertBack(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new System.NotImplementedException();
        }
    }
}
